CmdLine parsing was extracted from XMake and the implementation is visible to dotnet (attempt 2)#12836
Merged
MichalPavlik merged 16 commits intomainfrom Jan 16, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the FEATURE_GET_COMMANDLINE conditional compilation constant, standardizing the codebase to consistently use string[] for command line arguments across both .NET Framework and .NET (Core). The change simplifies the codebase by eliminating platform-specific code paths that are no longer necessary since .NET supports string[] entry points directly.
Key changes:
- Added
BuildEnvironmentHelper.IsRunningOnCoreClrproperty to distinguish runtime types - Updated all public and internal APIs to accept
string[]instead of conditionally usingstringorstring[] - Modernized test code to use C# collection expressions (
[]instead ofnew[]) - Added API compatibility suppressions for experimental APIs that changed signatures
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/BuildEnvironmentHelper.cs | Added IsRunningOnCoreClr property to detect .NET vs .NET Framework runtime |
| src/MSBuild/XMake.cs | Removed conditional compilation, standardized to string[] parameters, prepends executable path on CoreCLR |
| src/MSBuild/MSBuildClientApp.cs | Updated method signatures to consistently use string[] parameters |
| src/MSBuild.UnitTests/XMake_Tests.cs | Modernized tests to use collection expressions |
| src/MSBuild.UnitTests/ProjectSchemaValidationHandler_Tests.cs | Modernized tests to use collection expressions (with one interpolation bug) |
| src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs | Modernized tests to use collection expressions |
| src/Directory.BeforeCommon.targets | Removed FEATURE_GET_COMMANDLINE constant definition |
| src/Build/CompatibilitySuppressions.xml | Added suppressions for breaking changes in experimental APIs |
| src/Build/BackEnd/Node/ServerNodeBuildCommand.cs | Updated command line field and constructor to use string[] |
| src/Build/BackEnd/Node/OutOfProcServerNode.cs | Updated BuildCallback delegate signature to accept string[] |
| src/Build/BackEnd/Client/MSBuildClient.cs | Updated constructor and internal logic to use string[] |
| src/Build.UnitTests/Utilities_Tests.cs | Modernized test to use collection expressions |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
MichalPavlik
commented
Dec 4, 2025
MichalPavlik
commented
Dec 4, 2025
MichalPavlik
commented
Dec 4, 2025
…ically. ICommandLineSwitechs was replaced by CommandLineSwitchesAccessor as a simple struct wrapper for CommandLineSwitches.
…ed forgotten empty region in CommandLineSwitches.
baronfel
approved these changes
Jan 13, 2026
Member
baronfel
left a comment
There was a problem hiding this comment.
This looks very usable, and the Experimental namespace helps protect us when we need to iterate on it later 👍
Member
Author
|
Do not merge until new VMR check is done. |
This was referenced Jan 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #839
Context
In some cases dotnet needs to process MSBuild command line switches including response files (.rsp).
Changes Made
FEATURE_GET_COMMANDLINEworkaround is no longer needed and it was removed. Parsing methods are now usingIEnumerable<string>instead ofstring. Parsing logic was extracted fromXMaketoCommandLineParserclass.Testing
All existing tests are passing.
VMR: https://dev.azure.com/dnceng/internal/_build/results?buildId=2879901&view=results
Notes
MSBuildClientshouldn't be used outside MSBuild.OutOfProcServerNode.BuildCallbackdelegate shouldn't be used anywhere. This delegate (and whole type) are public just because we are not able to expose internal types with MSBuild project due to shared sources in both projects. We had to useExperimentalnamespace instead.How to review
All commits except the last one was a preparation - removing
FEATURE_GET_COMMANDLINEconstant and migration to vector of strings in our implementations. Last commit extracts the parsing logic toCommandLineParserclass.